import { createRouter, createWebHistory } from 'vue-router'
import DashboardView from '@/views/DashboardView.vue'

const routes = [
  {
    path: '/',
    name: 'dashboard',
    component: DashboardView,
    meta: {
      title: '仪表盘',
    },
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@/views/LogSearchView.vue'),
    meta: {
      title: '日志检索',
    },
  },
  {
    path: '/topo-config',
    name: 'topo-config',
    component: () => import('@/views/TopoConfigView.vue'),
    meta: {
      title: '拓扑配置',
    },
  },
  {
    path: '/topo-analysis',
    name: 'topo-analysis',
    component: () => import('@/views/LogDataTopoView.vue'),
    meta: {
      title: '拓扑配置',
    },
  },
  {
    path: '/es-index-management',
    name: 'es-index-management',
    component: () => import('@/views/ESIndexManagementView.vue'),
    meta: {
      title: '拓扑配置',
    },
  },
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
})

router.beforeEach(to => {
  document.title = `${to.meta.title} - 日志分析系统`
})

export default router
